#ifndef __MISC_H__
#define __MISC_H__

#include "include.h"

/** @defgroup NVIC_Preemption_Priority_Group NVIC Preemption Priority Group
  * @{
  */
#define NVIC_PRIORITYGROUP_0                    0x00000007U /*!< 0 bit  for pre-emption priority,
                                                                 3 bits for subpriority */
#define NVIC_PRIORITYGROUP_1                    0x00000006U /*!< 1 bit  for pre-emption priority,
                                                                 2 bits for subpriority */
#define NVIC_PRIORITYGROUP_2                    0x00000005U /*!< 2 bits for pre-emption priority,
                                                                 1 bits for subpriority */
#define NVIC_PRIORITYGROUP_3                    0x00000004U /*!< 3 bits for pre-emption priority,
                                                                 0 bit  for subpriority */

void LL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup);
void LL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority);
void LL_NVIC_EnableIRQ(IRQn_Type IRQn);
void LL_NVIC_DisableIRQ(IRQn_Type IRQn);
void LL_NVIC_SystemReset(void);

#define SYSTICK_DEFAULT_PRIO                    ((1UL << __NVIC_PRIO_BITS) - 1) /*!< Lowest Prio for SysTick */
#define SYSTICK_MAX_DELAY_TICK                  (0xFFFFFFFFU)

void LL_SysTickInit(uint32_t TickFreq, uint32_t TickPrio);
void LL_SysTickInc(void);
uint32_t LL_SysTickGet(void);
void LL_SysTickDly(uint32_t DelayTicks);

#endif
